package com.example;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ListDemo extends ListActivity {
	private static final String[] COUNTRIES = { "Viet Nam", "Thuy Dien", "Lao",
			"Campuchia", "Vienne" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(
				getBaseContext(), android.R.layout.simple_list_item_single_choice,
				COUNTRIES);
		ListView listView = getListView();
		listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
		setListAdapter(adapter);

	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		l.setItemChecked(position, l.isItemChecked(position));
		Toast.makeText(getBaseContext(), COUNTRIES[position], Toast.LENGTH_SHORT).show();
	}
}
